<?php
/**
 * Created by 张彪.
 * User: 小马出行
 * Date: 2018/4/18
 * Time: 11:34
 */
namespace app\admin\inter_model;
use app\inter\model\InterBase;
use think\Db;

class AllotLogModel extends InterBase
{
    public function getAllotLog($map,$field='a.*',$flag = true,$page=1,$limit=10,$config='')
    {
        $config = $config?:$this->config;
        return  $flag ? Db::connect($config)->name('allot_log a')
            ->join($config['database'].'.xm_admin b','a.admin_id=b.admin_id','LEFT')
            ->join(['xm_driver_base'=>'c'],'a.driver_id=c.driver_id','LEFT')->join('order_common d','a.common_id=d.id','LEFT')
            ->where($map)->field($field)->page($page,$limit)->order('log_id desc')->select()
           : Db::connect($config)->name('allot_log a')
                ->join($config['database'].'.xm_admin b','a.admin_id=b.admin_id','LEFT')
                ->join(['xm_driver_base'=>'c'],'a.driver_id=c.driver_id','LEFT')->join('order_common d','a.common_id=d.id','LEFT')
                ->where($map)->field($field)->find();
    }

    public function allotLogCount($map,$config='')
    {
        $config = $config?:$this->config;
        return  Db::connect($config)->name('allot_log a')
            ->join($config['database'].'.xm_admin b','a.admin_id=b.admin_id','LEFT')
            ->join(['xm_driver_base'=>'c'],'a.driver_id=c.driver_id','LEFT')->join('order_common d','a.common_id=d.id','LEFT')
            ->where($map)->count();
    }
}